﻿@model N03_11HCA_HTTTHD.Models.Admin_QuanLyTinTuc
@{
    ViewBag.Title = "Ban quản trị - Quản lý tin tức";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

@section TimKiemImport{
    <div class="filtering">
        <label for="tieuDe">Tiêu đề: </label>
        <input type="text" name="tieuDe" id="tieuDe" />    
        <label for="noiDung">Nội dung: </label>
        <input type="text" name="noiDung" id="noiDung" />        
        <button type="submit" id="LoadRecordsButton">Lọc dữ liệu</button>
    </div>
}

@section JavaScriptCSSImport{
    <link href="@Url.Content("~/Content/mycontent/list_counter.css")" rel="stylesheet" type="text/css"/>
}
@section JavaScriptDocumentReady{
    $('#danhSachTinTuc').jtable({
            tableId: "tableTinTuc",
            title: 'Danh sách tin tức',
            pageSize: 20,
            paging: true,
            sorting: true,
            defaultSorting: 'NgayDang DESC',
            selecting: true, //Enable selecting
            //multiselect: true, //Allow multiple selecting
            //selectingCheckboxes: true, //Show checkboxes on first column
            //selectOnRowClick: false, //Enable this to only select using checkboxes
            actions: {
                listAction: '/Admin/DanhSachTinTuc',
                deleteAction: '/Admin/XoaTinTuc',
                updateAction: '/Admin/CapNhatTinTuc',
                createAction: '/Admin/ThemTinTuc'
            },

            fields: {
                ID: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false,
                    sorting: false
                },
                TieuDe : {
                    title: 'Chủ đề',
                    width: '15%',
                    create: true,
                    edit: true,
                    list: true,
                    sorting: true,
                    listClass: "td_autohide"
                },
                NoiDung : {
                    title: 'Nội dung',
                    type: 'textarea',
                    create: true,
                    edit: true,
                    list: false,
                    sorting: false,
                    listClass: "td_autohide"
                },
                Xoa: {
                    title: 'Trạng thái',
                    create: false,
                    edit: true,
                    list: true,
                    sorting: true,
                    type: 'checkbox',
                    values: { 'false': 'Hoạt động', 'true': 'Bị xóa' },
                },
                NgayDang: {
                    title: 'Thời gian',
                    type: 'date',
                    displayFormat: 'dd/mm/yy',
                    create: false,
                    edit: false,
                    list: true,
                    sorting: true
                }
               
            }
        });

        //Load student list from server
        $('#danhSachTinTuc').jtable('load');
        //$('table.jtable').css("table-layout","fixed");

         //Filter
        //Re-load records when user click 'load records' button.
        $('#LoadRecordsButton').click(function (e) {
            e.preventDefault();
            $('#danhSachTinTuc').jtable('load', {
                tieuDe: $('#tieuDe').val(),
                noiDung: $('#noiDung').val()
            });
        });
}


<!-- Container for jTable -->
<div id="danhSachTinTuc"></div>
